<template>
	<view class="wrapper">
		<head-title titleText="赚钱攻略" showLeftButton="true"></head-title>
		<view class="topCont">
			<image src="../../static/image/topBg.png" mode="aspectFill"></image>
		</view>
		<view class="cont">
			<view class="title">
				<image src="../../static/image/txt1.png" mode="aspectFill"></image>
			</view>
			<view class="list">
				该软件是一款<text class="h_blue">交友与赚钱</text>集一体的社交小程序。
			</view>
			<view class="list">
				每天活跃，收到他人赠送礼物的机会越大。
			</view>
			<view class="list">
				收到的礼物都可以<text class="h_blue">兑换</text>成为现金提现。
			</view>
			
			
			<view class="title shares">
				<image src="../../static/image/txt2.png" mode="aspectFill"></image>
			</view>
			<view class="list">
				点击<text class="h_red">保存图片</text>保存到您的相册，发布到朋友圈。
			</view>
			<view class="list">
				<text class="h_blue">"分享越多，赚钱机会越多"</text>让更多人关注你吧
			</view>
			<view class="list">
				点击 分享赚钱 转发到微信群或好友。
			</view>
			<image class="imgs" src="https://yp.6vx.com/data/sys_img/other_img/zhuan.jpg" mode="aspectFill"></image>
			<view class="btnCont flex_row">
				<button class="btn share" open-type="share" type="primary">分享赚钱</button>
				<button @tap="keepImg" class="btn keep" type="primary">保存图片</button>
			</view>
		</view>
	</view>
</template>

<script>
	import headTitle from "../../components/headTitle.vue";
	import common from "../../common/network.js";
	var session = '';
	export default {
		components:{headTitle},
		data(){
			return{
				msg:''
			}
		},
		onLoad:function(options){
			if(options.session!=undefined){
				session = options.session;
				this.getImg();
			}
		},
		onShareAppMessage:function(){
			var msg = this.msg;
			return {
			   title: msg.c_title,
			   path: '/pages/index/index',
			   imageUrl: msg.c_img
			}
		},
		methods:{
			getImg:function(){
				var that = this;
				var $data = {
					'type':'zshare_share_qian',
					'session':session,
					'c_type':1,
				};
				common.network.request($data,function(res){
					console.log(res);
					that.msg = res;
				})
			},
			keepImg:function(){
				var that = this;
				var arr = [
					"https://yp.6vx.com/data/sys_img/share/sharePic1.jpg",
					"https://yp.6vx.com/data/sys_img/share/sharePic2.jpg"
				];
				var num = Math.round((Math.random()*1));
				console.log(num)
				uni.downloadFile({
					url: arr[num],
					success:function(res){
						uni.saveImageToPhotosAlbum({
							filePath: res.tempFilePath,
							success:function(){
								uni.showModal({
									showCancel:false,
									content:'成功保存到你的相册，你可以去相册查看和分享',
									confirmColor:'#6278FF',
								})
							}
						})
					}
				})
			}
		}
	}
</script>

<style scoped>
	.topCont image{
		width: 100%;
		height: 44px;
	}
	.cont{
		padding: 0 30px;
	} 
	.title{
		padding: 40px 0 14px 0;
		text-align: center;
	}
	.title image{
		width: 285px;
		height: 32px;
	}
	.shares{
		padding-top: 50px;
	}
	.shares image{
		width: 270px;
		height: 32px;
	}
	.list{
		padding: 5px 0;
		line-height: 44px;
		font-size: 28px;
		text-align: center;
		word-break: break-all;
	}
	.imgs{
		width: 100%;
		height: 400px;
		border-radius: 14px;
		margin-top: 30px;
	}
	.h_red{
		color: #EE463B;
	}
	.h_blue{
		color: #6278FF;
	}
	.btnCont{
		justify-content: space-between;
		margin-top: 30px;
		margin-bottom: 50px;
	}
	.btnCont .btn{
		width: 47.5%;
		border-radius: 10px;
		font-size: 30px;
		border: 1px solid #6278FF;
		margin: 0;
	}
	.btn.share{
		background: #fff;
		color: #6278FF;
	}
	.btn.keep{
		background: #6278FF;
	}
</style>
